package adt;
import kernel.CPU;

/**
 * 
 * @author Aaron Fung
 *		   Chris Ren
 * @version 1.0	
 */

public abstract class CPUprocess{

	private ProcessControlBlock my_pcb = new ProcessControlBlock();
	private int pid;
	
	
	/**
	 * Construct that takes an int as it's process ID.
	 * @param the_pid the process id.
	 */
	public CPUprocess(final int the_pid) {
		pid = the_pid;
	}
	
	/**
	 * Output to the screen. 
	 * The process stop for 10 ms.
	 */
	public abstract void proceessoutput();

	
	/**
	 * 
	 * @return the PCB.
	 */
	public ProcessControlBlock getPCB()
	{
		return my_pcb;
	}
	
	
	/**
	 * 
	 * @return the Process id. 
	 */
	public int getPid()
	{
		return pid;
	}
	
	
	/**
	 * 
	 * @return if the process is an idle process, default set to false.
	 */
	public boolean isIdle()
	{
		return false;
	}
	
	/**
	 * return true if the two process's id is equal.
	 */
	@Override
	public boolean equals(Object the_obj)
	{
		boolean result = false;
		//System.out.print("pid:" + getPid() + ", " + ((CPUprocess)the_obj).getPid());
		if (the_obj.getClass().equals(getClass()) )
		{
			if (getPid() == ((CPUprocess)the_obj).getPid())
			{
				
				result = true;
			}
		}
		//System.out.print(" "+ result + "\n");
		return result; 
		
	}

	/**
	 * return process info including the pid and type of process.
	 */
	public abstract String toString();
	
	/**
	 * 
	 * @return the type of service request.
	 */
	public abstract CPU.Request getRequest();
	
	
}
